import { Node } from '@xyflow/react';

// 定义节点参数类型
export interface NodeParams {
  cleaning_type?: string;
  columns?: string;
  threshold?: number;
  strategy?: string;
  fill_value?: string;
  method?: string;
  with_mean?: string;
  with_std?: string;
  feature_range?: string;
  quantile_range?: string;
  file?: File;
  filename?: string;
  processedData?: any[];
  separator?: string;
  encoding?: string;
  outlier_method?: string;
  z_score_threshold?: number;
  iqr_multiplier?: number;
  duplicate_strategy?: string;
  format_rules?: string;
  max_rows?: number;
  page_size?: number;
  filePath?: string;
  source_node?: string;
  row_count?: number;
  column_count?: number;
  sheet_name?: string;
  feature_selection_method?: string;
  k_best?: number;
  variance_threshold?: number;
  correlation_threshold?: number;
  target_column?: string;
  feature_columns?: string[];
  [key: string]: any;
}

// 定义节点数据类型
export interface NodeData extends Record<string, unknown> {
  type: string;
  label?: string;
  params?: {
    file?: File;
    filePath?: string;
    feature_selection_method?: string;
    k_best?: number;
    variance_threshold?: number;
    correlation_threshold?: number;
    target_column?: string;
    feature_columns?: string[];
    [key: string]: unknown;
  };
  lastExecutionResult?: {
    metrics?: {
      accuracy: number;
      precision: number;
      recall: number;
      f1: number;
      confusion_matrix?: number[][];
      roc_curve?: {
        fpr: number[];
        tpr: number[];
        thresholds: number[];
        auc: number;
      };
    };
    feature_importance?: Record<string, number>;
    training_info?: {
      n_features: number;
      n_samples_train: number;
      n_samples_test: number;
      classes: any[];
      model_type: string;
    };
    data?: any[];
    columns?: string[];
    selected_features?: string[];
    original_features?: string[];
    feature_scores?: Record<string, number>;
    stats?: Record<string, any>;
    row_count?: number;
    sheet_name?: string;
    available_sheets?: string[];
  };
}

// 自定义节点类型
export interface CustomNode extends Node<NodeData> {}

// 节点分类
export enum NodeCategory {
  DataInput = 'dataInput',
  DataProcessing = 'dataProcessing',
  FeatureSelection = 'featureSelection',
  MachineLearning = 'machineLearning',
  DataAnalysis = 'dataAnalysis',
  Visualization = 'visualization',
  Output = 'output'
}

// 节点类型常量
export enum NODE_TYPES {
  CSV_READER = 'csv_reader',
  EXCEL_READER = 'excel_reader',
  DB_READER = 'db_reader',
  DATA_CLEANING = 'data_cleaning',
  DATA_STANDARDIZATION = 'data_standardization',
  OUTLIER_DETECTION = 'outlier_detection',
  ONE_HOT_ENCODING = 'one_hot_encoding',
  FEATURE_SELECTION_FILTER = 'feature_selection_filter',
  LOGISTIC_REGRESSION = 'logistic_regression',
  RANDOM_FOREST = 'random_forest',
  SVM = 'svm',
  STRUCTURED_VIEW = 'structured_view',
  BAR_CHART = 'bar_chart',
  LINE_CHART = 'line_chart',
  SCATTER_PLOT = 'scatter_plot',
  PIE_CHART = 'pie_chart',
  HEATMAP = 'heatmap',
  MODEL_EVALUATION = 'model_evaluation'
} 